|
|
|
|
|
|
|
Save the module as MODODBC.BAS, and save the project as PRJODBC.VBP. Now you are ready to build the library functions that use these API calls to perform ODBC operations. |
|
|
|
|
|
|
|
|
The ODBC Library Routines |
|
|
|
|
|
|
|
|
The next set of routines are separated into two groups. The first group are routines that deal primarily with the ODBC interface. These routines are just wrappers for the API calls. Wrappers are Visual Basic routines that encapsulate the API call. Using wrappers makes it easy to change the underlying API call without having to change your code. If you want to use the 16-bit version of the ODBC, for example, you only need to change the ODBC32.DLL reference in each of the API calls to ODBC.DLL. Because you are using Visual Basic wrappers, you won't have to make any changes to your Visual Basic programs in order to use 16-bit ODBC. |
|
|
|
|
|
|
|
|
The second set of library routines deals primarily with Visual Basic. These routines take the data from the ODBC and store it in Visual Basic variables and controls for use on your data-entry forms. |
|
|
|
|
|
|
|
|
First, you need to add a few global variables that you use throughout the library. Select the default class module for the project and set its Name property to objODBC. Now add the declarations in Listing 19.3 to the file. |
|
|
|
|
|
|
|
|
Listing 19.3. Adding the local variables to LIBODBC.BAS. |
|
|
|
|
|
|
|
|
Option Explicit
'
'
Private Const BUFFERLEN = 256
'
' sql lock types
Public Enum sqlLockType
sqlreadonly = 1
sqllock = 2
sqlrowver = 3
sqlValues = 4
End Enum
'
' sql cursor drivers
Public Enum sqlCursorDriverType
sqluseifneeded = 0
sqlUseODBC = 1
sqlUseDriver = 2
End Enum
'
' cursor types
Public Enum sqlResultSetType |
|
|
|
|
|